
using System;


namespace DailyFx.Book
{

	public class RowImpl : IRow
	{
		/// <summary>
		///		Contains the values of the <see cref="RowImpl"/>
		/// </summary>
		protected /*readonly*/ Object[] _values;

		/// <summary>
		///		Contains the header of the <see cref="RowImpl"/>
		/// </summary>
		protected /*readonly*/ Schema _schema;

		/// <summary>
		///		Indicates the status of the record .
		/// </summary>
		private Status _status;


		/// <summary> 
		///		c'tor .
		/// </summary> 
		public RowImpl( Schema schema, Object[] values)
		{
			/**
			if (header == null) {
				throw new ArgumentNullException("fields");
			}
			if (values == null) {
				throw new ArgumentNullException("values");
			}
			if (header.Count != values.Length) {
				throw new ArgumentException ("Fields' cout not matches the values' count");
			}
			*/

			this._schema = schema;
			this._values = values;
			
		}

	

		/// <summary> 
		///		Gets the <see cref="Schema"/> of record fields. 
		/// </summary> 
		public Schema Schema
		{
			get { return this._schema; }
		}

		/// <summary>
		///		Gets the <see cref="Status"/> of the record .
		/// </summary>
		public Status Status
		{
			get { return this._status; }
		}

		/// <summary>
		///		Gets the count of fields in the record .
		/// </summary>
		public int Count
		{
			get { return this._values.Length; }
		}

		/// <summary>
		///		Checks if value of the specified field is not available .
		/// </summary>
		public Boolean IsNull ( Int32 index )
		{
 			// todo:
			return this._values [ index ] == null;
		}

		/// <summary>
		///		Gets the time stamp field of this record .
		/// </summary>
		public DateTime Key
		{
			get { return (DateTime)this._values[0]; }
		}

		/// <summary> 
		///		Gets value by the specified field. 
		/// </summary> 
		public Object this [ Int32 index ]
		{
			get
			{
				return this._values [index];
			}
		}

		/// <summary> 
		///		Gets value by the specified field. 
		/// </summary> 
		public Object this [ String fLabel ]
		{
			get
			{
				Int32 ordinal = this._schema.GetFieldIndex( fLabel);
				return this._values[ ordinal];
			}
		}
	} 



}